// Filename: app.js
define([
  'jquery',
  'underscore',
  'backbone',
  'router' // Request router.js
], function($, _, Backbone, Router){
	  var initialize = function(){
		// Pass in our Router module and call it's initialize function
		Router.initialize();
		
		//To be used in case of remote server rest calls. Always needed
		//commented as client and server is on dev machine
		//$.ajaxPrefilter(function (options, originalOptions, jqXHR){
		//	options.url = 'http://localhost:8080' + options.url;			
		//});
		
		//To be used in case of remote server rest calls. Always needed
		//commented as client and server is on dev machine
		//$.ajaxPrefilter(function (options, originalOptions, jqXHR){
		//	options.url = 'http://localhost:8080' + options.url;			
		//});
		
		$.fn.serializeObject = function() {
		    var o = {};
		    var a = this.serializeArray();
		    $.each(a, function() {
		        if (o[this.name] !== undefined) {
		            if (!o[this.name].push) {
		                o[this.name] = [o[this.name]];
		            }
		            o[this.name].push(this.value || '');
		        } else {
		            o[this.name] = this.value || '';
		        }
		    });
		    return o;
		};
		
	  }

	  return {
		initialize: initialize
	  };
});